package com.mxpio.erp.common.inventory.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@Entity
@Table(name = "V_MB_ERP_INV_STOCK")
@Schema(description="实时库存")
@NoArgsConstructor
@AllArgsConstructor
public class VInvStock implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;


	@Id
	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;
	
/*	@Id
	@Column(name = "LOT_NO_")
	@Schema(description = "批次")
	private String lotNo;*/
	
	@Id
	@Column(name = "WH_CODE_")
	@Schema(description = "仓库代码")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;
	
	@Column(name = "ALL_QUANTITY_")
	@Schema(description = "合计数量")
	private BigDecimal allQuantity;

	@Column(name = "QUANTITY_")
	@Schema(description = "可用数量")
	private BigDecimal quantity;

	@Column(name = "HOLD_QUANTITY_")
	@Schema(description = "锁定数量")
	private BigDecimal holdQuantity;

	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName;

	@Column(name = "ITEM_GROUP_CODE_")
	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;

	@Column(name = "ITEM_SPEC_")
	@Schema(description = "物料规格")
	private String itemSpec;

	@Column(name = "UNIT_CODE_")
	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	/*@Column(name = "IMG_FILE_")
	@Schema(description = "图片路径")
	private String imgFile;*/


	@Column(name = "WH_TYPE_")
	@Schema(description = "仓库类别")
	@Dict(dicCode = "ERP_INV_WH_TYPE")
	private String whType;

	@Column(name = "DRAWING_NO_")
	@Schema(description = "图号")
	private String drawingNo;

	@Column(name = "CREATE_TIME", updatable = false)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "创建时间")
	private Date createTime;

	//lot_status_
/*	@Column(name = "LOT_STATUS_")
	@Schema(description = "批次状态")
	private String lotStatus;*/

	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}

}
